<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>

<%@ page import="com.conversationboard.model.*" %>
<%@ page import="com.conversationboard.view.*" %>
<%@ page import="java.security.Principal" %>
<%@ page import="com.conversationboard.config.*" %>
<%@ page import="com.conversationboard.site.*" %>
<%@ page import="com.conversationboard.authenticator.AuthenticationCookie"%>
<%@ page import="com.conversationboard.tree.Folders"%>
<%@ page import="com.conversationboard.tree.Node"%>
<%@ page import="java.util.List"%>
<%@ page import="java.sql.Connection"%>
<%@ page import="com.conversationboard.database.Database"%>
<%@ page import="java.sql.PreparedStatement"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page import="java.sql.ResultSetMetaData"%>
<%@ page import="com.conversationboard.view.resultsettable.ResultSetTable"%>
<%@ page import="com.conversationboard.database.Queries"%>

<%@ page pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>

<%
	/* Get user information and perform security checks */

    Principal principal = request.getUserPrincipal();
    String userName = null;
    
    if (principal != null) {
    	userName = principal.getName();
    }
    
 	User user = User.get(userName);
 	Bookmarks bookmarks = user.getBookmarks();
 	
 	if (!user.isSiteAdmin()) {
 		return;
 	}
 	
 	String loginId = request.getParameter("loginId");

 	User banUser = User.get(loginId);
 	
 	String[] headings = {"Login ID", "Display Name", "Original Display Name", "Message", "Link to Message", "Timestamp"};
 	
 	/* Perform database query */
 	
 	Connection connection = null;
 	
 	try {
 		
 		connection = Database.getConnection();
 		PreparedStatement statement = connection.prepareStatement(Queries.SUGGEST_BANS_FROM_USER);
 		
 		statement.setString(1, loginId);
 		
 		statement.execute();
 		
 		ResultSet resultSet = statement.getResultSet();

 		ResultSetTable table = new ResultSetTable();
 		table.setLink(1, Configuration.getInstance().getRoot() + "/Admin/AdminUserInfoControllerServlet", "User Info", false);
 		table.setLink(5, Configuration.getInstance().getRoot() + "/ThreadSelectedControllerServlet", "Link", false);
 		
 		String output = table.display(user, headings, resultSet, userName);
%>



<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta name="ROBOTS" content="NOINDEX"></meta>
	<title><%=Configuration.getInstance().getSiteName()%></title>
	<link rel="stylesheet"title="Conversation Board" type="text/css" href="${contextPath}/Stylesheets/<%=StyleSheets.getStyleSheetFileName(request.getCookies())%>">
</head>

<body>

	<%= MainMenu.display(principal) %>

	<% if (SiteMessage.getMessage() != null) { %>	
		<div class='sitemessage'><%= SiteMessage.getMessage() %></div>
	<% } %>

	<% if (BatchMessage.getMessage() != null) { %>	
		<div class='batchmessage'><%= BatchMessage.getMessage() %></div>
	<% } %>
	
	<% if (user.isSiteAdmin() && (Site.getPendingRegistrations() > 0)) { %>
		<div class='batchmessage'><%= Site.getPendingRegistrations() %> pending registration(s).</div>
	<% } %>

	<%= BookmarksDisplay.display(bookmarks, false) %>

	<c:if test="${siteshut}">
		<div class="sitemessage"><strong><span class="red">Site is currently shut. You are accessing as an administrator. Open the site in the admin menu option <a href="${contextPath}/Pages/Admin/openclose.jsp">Open/Close Site</a></span></strong></div>
	</c:if>


	<div class="headingblock">
		<h1>Who Has This User Suggest Be Banned?</h1>
	</div>

	<div class="mainblock">
	
	<%= output %>

	<%
 	} finally {
 		Database.close(connection);
 	}
	%>
	
	</div>

</body>
</html>
